// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'


//把axios引进来**************************************
import axios from 'axios'
//axios默认请求不携带cookie,需全局配置
axios.defaults.withCredentials = true
Vue.prototype.ajax = axios

//把jquer引进来************************需要现在配置文件中配置
import $ from 'jquery'

//把mint-ui UI组件库 引进来 *******************引入js和css
import Mintui from 'mint-ui'
import 'mint-ui/lib/style.css'
Vue.use(Mintui)

//把 vee-validate vue-i18n 表单验证组件引进来***************************

import VeeValidate, {
	Validator
} from 'vee-validate';
import zh_CN from 'vee-validate/dist/locale/zh_CN'
import VueI18n from 'vue-i18n';

Vue.use(VueI18n)
const i18n = new VueI18n({
	locale: 'zh_CN',
})
Vue.use(VeeValidate, {
	i18n,
	i18nRootKey: 'validation',
	dictionary: {
		zh_CN
	}
});

/*自定义验证规则*/
//身份证号
Validator.extend('idCard', {
	getMessage: field => "身份证号码格式不正确",
	validate: value => {
		return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value);
	}
});
//手机号
Validator.extend('phone', {
	getMessage: field => "手机号码格式不正确",
	validate: value => {
		return /^1[3-8]\d{9}$/.test(value);
	}
});
//银行卡号
Validator.extend('bankCode', {
	getMessage: field => "银行卡号不正确",
	validate: value => {
		return /^([1-9]{1})(\d{14}|\d{18})$/.test(value);
	}
});

/*自定义提示信息*/
const dict = {
	zh_CN: {
		messages: {
			required: (name) => `${name}不能为空！`,
			confirmed: (name) => `两次密码输入不一致！`,
		}
	} // name接受alias的值.
}
Validator.localize(dict);
//***************************************************************************


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
	el: '#app',
	router,
	components: {
		App
	},
	template: '<App/>'
})